package cn.hamster3.mc.plugin.ball.common.listener;

import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo;
import cn.hamster3.mc.plugin.ball.common.event.message.MessageReceivedEvent;
import cn.hamster3.mc.plugin.ball.common.event.message.MessageSentEvent;
import cn.hamster3.mc.plugin.ball.common.event.player.BallPlayerInfoUpdateEvent;
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
import com.google.common.eventbus.Subscribe;

public class BallDebugListener {
    public static final BallDebugListener INSTANCE = new BallDebugListener();

    private BallDebugListener() {
    }

    @Subscribe
    public void onMessageReceived(MessageReceivedEvent event) {
        BallAPI.getInstance().getLogger().info("收到了一条消息: " + event);
    }

    @Subscribe
    public void onMessageSent(MessageSentEvent event) {
        BallAPI.getInstance().getLogger().info("发送了一条消息: " + event);
    }

    @Subscribe
    public void onBallPlayerInfoUpdate(BallPlayerInfoUpdateEvent event) {
        BallPlayerInfo playerInfo = event.getPlayerInfo();
        String json = CoreAPI.getInstance().getGson().toJson(playerInfo);
        BallAPI.getInstance().getLogger().info("更新了玩家 " + playerInfo.getName() + " 的信息: " + json);
    }
}
